package csu.jpetstore.jpetstore.service;

import csu.jpetstore.jpetstore.domain.Orders;
import csu.jpetstore.jpetstore.repository.OrdersRepository;
import csu.jpetstore.jpetstore.utils.Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OrderService {
    @Autowired
    OrdersRepository ordersRepository;

    public void updateOrder(Orders orders){
        ordersRepository.save(orders);
    }
    public List<Orders> getOrderByOrderId(String orderId){
        return ordersRepository.findAllByOrderId(orderId);
    }
    public List<Orders> getOrderByUserid(String userid){
        return ordersRepository.getAllByUser_Id(userid);
    }
    public List<Orders> findAll(){
        return ordersRepository.findAll();
    }
    public void delete(String orderId){
        ordersRepository.deleteAllByOrderId(orderId);
    }
}
